﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using cwtrock.util;
using cwtrock.model;
using cwtrock.service.impl;

namespace cwtrock.view.sysmng
{
    public partial class SolverAdd : Form
    {
        private SysSolverServiceImpl service = new SysSolverServiceImpl();
        private SolverFrm parentFrm;
        private int id;

        public SolverAdd(SolverFrm parentFrm, int id)
        {
            InitializeComponent();
            this.parentFrm = parentFrm;
            this.id = id;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string code = this.textBox1.Text;
            bool flagCode = SimpleTool.isEmpty(code);
            if (flagCode)
            {
                MessageBox.Show("请填写结算方式", "提示信息", MessageBoxButtons.OK);
                return;
            }
            SysSolver sc = new SysSolver();
            if (id > 0)//修改当前记录
            {
                sc.ID = id;
                sc.KEYWORD = code;
                service.update(sc);
            }
            else
            {
                sc.KEYWORD = code;
                service.save(sc);
            }
            parentFrm.refresh();
            this.Hide();
        }

        private void SolverAdd_Load(object sender, EventArgs e)
        {
            SysSolver c = this.service.getSolvers(id);
            this.textBox1.Text = c.KEYWORD;
        }
    }
}
